<!--
 * @Descripttion: 
 * @version: 
 * @Author: wtzhang
 * @Date: 2021-08-02 13:53:34
 * @LastEditors: wtzhang
 * @LastEditTime: 2021-08-03 14:30:31
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>借助构造器初始化state，使用</title>
</head>

<body>
  <div id="app"></div>
  <script src="../js/old_version/react.development.js"></script>
  <script src="../js/old_version/babel.min.js"></script>
  <script src="../js/old_version/react-dom.development.js"></script>
  <script type="text/babel">
    // 创建类组件
    class Weather extends React.Component {
      constructor(props) {
        super()
        this.state = {
          isHot: false
        }
      }
      render(){
        console.log(this);
        let hot = this.state.isHot
        return <h3>今天天气好{hot ? '热' : '凉爽'}！</h3>
      }
    }
    // 渲染组件到页面
    // ReactDOM.render(虚拟DOM, 容器)
    ReactDOM.render(<Weather />, document.getElementById('app'))
  </script>
</body>

</html>